<template>
  <div>
    <Chart :cdata="cdata"/>
  </div>
</template>

<script>
    import Chart from './chart.vue'

    export default {
        data() {
            return {
                cdata: {
                    category: [
                        "1/1",
                        "1/2",
                        "1/3",
                        "1/4",
                        "1/5",
                        "1/6",
                        "1/7",
                        "1/8",
                        "1/9",
                        "1/10",
                        "1/11",
                        "1/12",
                        "1/13",
                        "1/14",
                        "1/15",
                        "1/16",
                        "1/17",
                        "1/18",
                        "1/19",
                        "1/20",
                        "1/21",
                        "1/22",
                        "1/23",
                        "1/24",
                        "1/25",
                        "1/26",
                        "1/27",
                        "1/28",
                        "1/29",
                        "1/30",
                        "1/31",
                        "平均",
                    ],
                    lineData: [
                        18092,
                        20728,
                        24045,
                        28348,
                        32808,
                        36097,
                        39867,
                        44715,
                        48444,
                        50415,
                        56061,
                        62677,
                        59521,
                        67560,
                        18092,
                        20728,
                        24045,
                        28348,
                        32808,
                        36097,
                        39867,
                        44715,
                        48444,
                        50415,
                        36097,
                        39867,
                        44715,
                        48444,
                        50415,
                        50061,
                        32677,
                        49521,
                    ],
                    barData: [
                        4600,
                        5000,
                        5500,
                        6500,
                        7500,
                        8500,
                        9900,
                        12500,
                        14000,
                        21500,
                        23200,
                        24450,
                        25250,
                        33300,
                        4600,
                        5000,
                        5500,
                        6500,
                        7500,
                        8500,
                        9900,
                        22500,
                        14000,
                        21500,
                        8500,
                        9900,
                        12500,
                        14000,
                        21500,
                        23200,
                        24450,
                        25250,
                    ],
                    rateData: []
                }
            };
        },
        components: {
            Chart,
        },
        mounted() {
            this.setData();
        },
        methods: {
            // 根据自己的业务情况修改
            setData() {
                for (let i = 0; i < this.cdata.barData.length - 1; i++) {
                    let rate = this.cdata.barData[i] / this.cdata.lineData[i];
                    this.cdata.rateData.push(rate.toFixed(2));
                }
            },
        }
    };
</script>

<style lang="scss" scoped>
</style>
